<template>
	<view>
		<view class="cu-custom" :class="[hasFixedFlag ? bgColor : '',currBg,currMod == 'sqMineMod' ? 'sqMineMod' : '']" :style="[{height:navHeight + 'px'}]">
			<view class="cu-bar posRel hasFlex" :style="style" :class="[bgImage != '' ? 'bg-img' : '']">
				<view class="action posAbso" :style="{height:navigationBarHeight + 'px',top:statusBarHeight + 'px'}" @tap="BackPage" v-if="isBack">
					<text class="iconfont icon-arrow" :style="{color:conCol}"></text>
					<slot name="backText"></slot>
				</view>
				<view class="content" :style="{color:conCol}" v-if="$slots.content">
					<slot name="content"></slot>
				</view>
				<slot name="search" :user="user" v-if="$slots.search"></slot>
				<slot name="tab" v-if="$slots.tab"></slot>
				<slot name="right" v-if="needRight"></slot>
			</view>
		</view>
		<view class="conBlock" v-if="needConBlock" :style="{marginTop:navHeight + 'px'}"></view>
	</view>
</template>

<script>
	import { systemInfo } from '@/mixins/systemInfo.js'
	export default {
		name: 'cu-custom',
		mixins:[systemInfo],
		props: {
			hasFixedFlag:{
				type:Boolean,
				default:false
			},
			bgColor: {
				type: String,
				default: ''
			},
			currBg:{
				type:String,
				defalut:''
			},
			isBack: {
				type: [Boolean, String],
				default: false
			},
			bgImage: {
				type: String,
				default: ''
			},
			conCol:{
				type:String,
				default:'#fff'
			},
			needRight:{
				type:Boolean,
				default:false
			},
			needConBlock:{
				type:Boolean,
				default:false
			},
			delta:{
				type:Number,
				defalut:1
			},
			currMod:{
				type: String,
				default: ''
			}
		},
		data() {
			return {
				StatusBar: 0,
				CustomBar: 0,
				user:{
					hasBack:this.isBack
				}
			};
		},
		mounted(){
			this.getSystemInfo();
		},
		computed: {
			style() {
				var StatusBar = this.statusBarHeight;
				var CustomBar = this.navigationBarHeight;
				var menuBarLeft = this.menuBarLeft;
				var bgImage = this.bgImage;
				//width:${menuBarLeft}px;
				var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
				if (this.bgImage) {
					style = `${style}background-image:url(${bgImage});`;
				}
				return style
			}
		},
		methods: {
			BackPage() {
				uni.navigateBack({
					delta:this.delta
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.cu-custom{
		width: 100%;
		position: fixed;
		top: 0;
		z-index: 1000;
		background: transparent;
		&.indexNav{
			// background: #FFC400;
			background: $pss-sq-main-bg;
			transition: .5s;
		}
		&.sqMineMod{
			background: $sq-fue;
		}
		&.zxsDet{
			background: #fff;
		}
		&.sqGk{
			background: $sq-fuf;
		}
		&.usuallyBg{
			background: $pss-sq-main-bg;
		}
		.cu-bar{
			align-items: center;
			.action{
				width: 40px;
				display: flex;
				align-items: center;
				left: 30rpx;
				.icon-arrow{
					font-size: 42rpx;
				}
			}
			.content{
				flex: 1;
				display: flex;
				justify-content: center;
				align-items: center;
				font-size: 32rpx;
			}
		}
	}
</style>
